package com.sunyy.codegenerator.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author sunyy
 * @date 2024/6/28
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Message<T> {

    /**
     * 提示
     */
    private String msg;
    /**
     * 成功与失败标识
     */
    private boolean success;
    /**
     * 数据
     */
    private T data;

    public static <T> Message<T> okWithNoMsg(T data) {
        return new Message<>("成功", true, data);
    }

    public static <T> Message<T> okWithNothing() {
        return new Message<>("成功", true, null);
    }

    public static <T> Message<T> ok(String msg, T data) {
        return new Message<>(msg, true, data);
    }

    public static <T> Message<T> error(String msg) {
        return new Message<>(msg, false, null);
    }
}
